# Maintainer: gym603 <gui_yuan_miao@163.com>

_realname=biopython
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python2-${_realname}" "${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
pkgver=1.74
pkgrel=2
pkgdesc="A set of freely available tools for biological computation written in Python (mingw-w64)"
arch=('any')
license=('Biopython')
url="https://biopython.org/"
makedepends=("${MINGW_PACKAGE_PREFIX}-python3-setuptools"
             "${MINGW_PACKAGE_PREFIX}-python2-setuptools")
source=(${_realname}-${pkgver}.tar.gz::https://biopython.org/DIST/${_realname}-${pkgver}.tar.gz)
sha256sums=('25152c1be2c9205bf80901fc49adf2c2efff49f0dddbcf6e6b2ce31dfa6590c0')

build() {
  cd "${srcdir}"
  rm -rf python{2,3}-build
  for builddir in python{2,3}-build; do
    cp -r ${_realname}-${pkgver} ${builddir}
    pushd $builddir
    ${MINGW_PREFIX}/bin/${builddir%-build} setup.py build
    popd
  done
}

package_python3-biopython() {
  depends=("${MINGW_PACKAGE_PREFIX}-python3-numpy")

  cd "${srcdir}/python3-build"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
    ${MINGW_PREFIX}/bin/python3 setup.py install --prefix=${MINGW_PREFIX} --root="${pkgdir}" -O1

  install -Dm644 LICENSE.rst "${pkgdir}${MINGW_PREFIX}/share/licenses/python3-${_realname}/LICENSE.rst"
}

package_python2-biopython() {
  depends=("${MINGW_PACKAGE_PREFIX}-python2-numpy")

  cd "${srcdir}/python2-build"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
    ${MINGW_PREFIX}/bin/python2 setup.py install --prefix=${MINGW_PREFIX} --root="${pkgdir}" -O1

  install -Dm644 LICENSE.rst "${pkgdir}${MINGW_PREFIX}/share/licenses/python2-${_realname}/LICENSE.rst"
}

package_mingw-w64-i686-python2-biopython() {
  package_python2-biopython
}

package_mingw-w64-i686-python3-biopython() {
  package_python3-biopython
}

package_mingw-w64-x86_64-python2-biopython() {
  package_python2-biopython
}

package_mingw-w64-x86_64-python3-biopython() {
  package_python3-biopython
}
